package com.youxuan.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class WebConfig implements WebMvcConfigurer {

    @Override
    public void addCorsMappings(CorsRegistry registry) {
        registry.addMapping("/**")
                //允许请求的域名
                .allowedOriginPatterns("*")
                //允许携带cookie
                .allowCredentials(true)
                //允许使用的请求方式
                .allowedMethods("GET","POST","PUT","DELETE","OPTIONS","PATCH")
                //允许携带的header属性
                .allowedHeaders("*")
                //跨域允许时间
                .maxAge(3600);
    }

}
